﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    
            <script>
                function getRandomIntInclusive(min, max) {
                    min = Math.ceil(min);
                    max = Math.floor(max);
                    return Math.floor(Math.random() * (max - min + 1) + min);
                }
                let brand = [];
                for (var i = 1; i < 14; i++) {
                    brand[i] = `♥${i}`;
                }
                for (var i = 14; i < 27; i++) {
                    brand[i] = `♠${i - 13}`;
                }
                for (var i = 27; i < 40; i++) {
                    brand[i] = `♣${i - 26}`;
                }
                for (var i = 40; i < 53; i++) {
                    brand[i] = `♦${i - 39}`;
                }
                brand[53] = `大王`;
                brand[54] = `小王`;
                function random(num1) {
                    let num = [];
                    let num2 = [];
                    let m = 0;
                    let brand1 = [];
                    let j = 0;
                    for (var i = 0; i < num1; ++i) {
                       
                        let flag = false;
                        num[i] = getRandomIntInclusive(1, 54);

                        for (var k = 0; k <= num2.length; k++) {
                            if (num2[k] == num[i]) {
                                flag = true;
                                i = i - 1;
                                break;
                            }
                        }
                        
                        
                        if (!flag) {
                            num2[m++] = num[i]

                        }
                        
                    }
                    for (var i of num2) {

                        brand1[j++] = brand[i];
                    }
                    
                    return brand1;
                }

                let cards = random(3);
                console.log(`底牌为  ${cards}`);
                let farmer1 = random(17);
                console.log(`农民1  ${farmer1}`);
                let farmer2 = random(17);
                console.log(`农民2  ${farmer2}`);
                let landowner = random(17);
                console.log(`地主  ${landowner}`);



            </script>

</body>
</html>